clc;
clear;
close all;


%% Paper
Vin=[40];
Iout=[1];
figure;
cc=hsv(4);
marker={'x-'; 'o-';'^-';'*-'};

%% hard
for i=1:length(Vin)
    file=sprintf('./data/impedance_vs_frequency/SC_impedance_frequency_hard_%iV_%iA_old.dat',Vin(i),Iout(i))
    M = csvread(file,1,0);
    efficiency=M(:,8);
    frequency=[length(M(:,2)):-1:1]*10+90;  % min frequency is 50 kHz
    plot(frequency,efficiency,marker{1},'color',cc(1,:),'LineWidth',0.75);
    hold all;
end
legendInfo{1} = 'Hard-charging';
%% Soft 1
for i=1:length(Vin)
    file=sprintf('./data/impedance_vs_frequency/SC_impedance_frequency_soft1_%iV_%iA_short.dat',Vin(i),Iout(i))
    M = csvread(file,1,0);
    efficiency=M(:,8);
    frequency=[length(M(:,2)):-1:1]*10+40;  % min frequency is 50 kHz
    plot(frequency,efficiency,marker{2},'color',cc(2,:),'LineWidth',0.75);
    hold all;
end
legendInfo{2} = 'Soft-charging';
%%  Split-phase
efficiency=[0.95606, 0.9538,0.95146,0.93853,0.93470];
frequency=[50, 75, 100, 150, 250];
loglog(frequency,efficiency,marker{3},'color',cc(3,:))
legendInfo{3} = 'Split-phase';
%%
xlabel('Frequency (kHz)');
ylabel('Efficiency');
legend(legendInfo,'Location','NorthEast');
grid on;
% ylim([65 100]);
xlim([0 410]);

set(gcf, 'Position', [200 200 450 300])
set(gcf,'PaperPositionMode','auto')
% print('-depsc2', '../Paper/images/efficiency_unregulated_exp');
% matlab2tikz( '../Paper/images/efficiency_unregulated_exp.tikz',  'height', '\figureheight', 'width', '\figurewidth','showInfo', false);
